package org.example.demosr4.dao;

import org.apache.ibatis.annotations.*;
import org.example.demosr4.entity.User;

@Mapper
public interface UserDao {
//    @Result(property = "name",column = "username")
    @Results(id = "userMap",value={
            @Result(property = "name",column = "name"),
            @Result(property = "password",column = "password")
    })
    @Select("select * from student where name= #{name}")
    User getStudentByName(@Param("name") String name);

    @Insert("insert into student(number,name,password) values (#{number},#{name},#{password})")
    int createStudent(User user);

    @Update("update student set name = #{name}, password = #{password} where number = #{number}")
    int updateStudent(User user);

    @Delete("delete from student where number = #{number}")
    int deleteStudent(@Param("number") String number);

}
